package com.anjubao.parking.municipal.payment.constant;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 *
 * @author zhuchunfeng
 * @date 2019/4/24 14:42
 */
public enum ChargingTypeEnum  {
    //计费方式 1:普通,2:月卡,3:年卡,4:免费
    COMMON(1, "普通"),
    MONTH_CARD(2, "月卡"),
    YEAR_CARD(3, "年卡"),
    FREE(4, "免费");

    @JsonValue
    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    ChargingTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private int code;

    private String desc;

    public static String getDescByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ChargingTypeEnum e : ChargingTypeEnum.values()) {
            if (e.getCode() == code) {
                return e.getDesc();
            }
        }
        return null;
    }

    public static Boolean exist(Integer code) {
        if (code == null) {
            return false;
        }
        for (ChargingTypeEnum e : ChargingTypeEnum.values()) {
            if (e.getCode() == code) {
                return true;
            }
        }
        return false;
    }
}
